using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Component;

public partial class Admin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Sessions.CurrentUser == null)
        {
            Response.Redirect("Login.aspx");
        }
        else
        {
            this.ChooseControl(this.GetQuery());
            ContentManagement contentMana = ContentManagementDB.GetObjectByid(18, true);
            if (contentMana.Priority == 1)
            {
                this.rbnPublic.Checked = true;
            }
            else
                this.rbnUnPublic.Checked = true;
        }
    }
    // fuction load control
    void LoadControlInCenter(string controlPath)
    {
        this.pnCenter.Controls.Clear();
        this.pnCenter.Controls.Add(LoadControl(controlPath));
    }
    // function get query
    string GetQuery()
    {
        try
        {
            return QueryHelper.GetQueryString(Request, ConstString._wand);
        }
        catch
        {
            return "";
        }
    }
    // func choose control
    void ChooseControl(string query)
    {
        this.pnTopmenu.Controls.Add(LoadControl(BackEndPath._TopMenu));
        switch (query)
        {
            #region
            case BackEndQuery._Login:
                this.pnTopmenu.Controls.Clear();
                Session.RemoveAll();
                Response.Redirect("Login.aspx");
                break;
            case BackEndQuery._UserChangePassword:
                LoadControlInCenter(BackEndPath._UserChangePassword);
                break;
            #endregion
            #region
            case BackEndQuery._ContentManagementL:
                LoadControlInCenter(BackEndPath._ContentManagementL);
                break;
            case ConstString.NewL:
                LoadControlInCenter(ConstString.NewBackEndL);
                break;
            case ConstString.NewM:
                LoadControlInCenter(ConstString.NewBackEndM);
                break;
            case ConstString.ServiceL:
                LoadControlInCenter(ConstString.ServiceBackEndL);
                break;
            case ConstString.ServiceM:
                LoadControlInCenter(ConstString.ServiceBackEndM);
                break;

            case BackEndQuery._CategoryL:
                LoadControlInCenter(BackEndPath._CategoryL);
                break;
            case BackEndQuery._CategorySubL:
                LoadControlInCenter(BackEndPath._CategorySubL);
                break;
            case Component.ConstString.Intro:
                LoadControlInCenter(ConstString.IntroPath);
                break;

            case Component.BackEndQuery._IntroductionImgL:
                LoadControlInCenter(BackEndPath._IntroductionImgL);
                break;
            case Component.BackEndQuery._GalleryL:
                LoadControlInCenter(BackEndPath._GalleryL);
                break;
            case BackEndQuery._TextStaticL:
                LoadControlInCenter(BackEndPath._TextStaticL);
                break;

            case BackEndQuery._ProductL:
                LoadControlInCenter(BackEndPath._ProductL);
                break;

            case Component.ConstString.CartDetail:
                LoadControlInCenter(ConstString.CartDetailBackEndL);
                break;

            case Component.BackEndQuery._ProductImgL:
                LoadControlInCenter(BackEndPath._ProductImgL);
                break;

            case BackEndQuery._ProductM:
                LoadControlInCenter(BackEndPath._ProductM);
                break;
            case BackEndQuery._TiGiaUSDVNDM:
                LoadControlInCenter(BackEndPath._TiGiaUSDVNDM);
                break;

                break;
            case ConstString._ServiceTransport:
                LoadControlInCenter(ConstString._PathAdminServiceTrans);
                break;
            default:
                LoadControlInCenter(BackEndPath._ContactL);
                break;

            #endregion
        }
    }

    protected void rbnPublic_CheckedChanged(object sender, EventArgs e)
    {
        this.rbnUnPublic.Checked = false;
        ContentManagement contentMana = ContentManagementDB.GetObjectByid(18, true);
        contentMana.Priority = 1;
        contentMana.Save();

    }
    protected void rbnUnPublic_CheckedChanged(object sender, EventArgs e)
    {
        this.rbnPublic.Checked = false;
        ContentManagement contentMana = ContentManagementDB.GetObjectByid(18, true);
        contentMana.Priority = 0;
        contentMana.Save();

    }
}
